package uestc.lj.basic.sort;

/**
 * 求数组中的最大值
 * @Author:Crazlee
 * @Date:2021/11/20
 */
public class Code05_GetMax {
    public static int getMax(int[] array) {
        return process(array, 0, array.length - 1);
    }

    private static int process(int[] array, int L, int R) {
        if (L == R) {
            return array[L];
        }
        int mid = L + (R - L) / 2;
        int leftMax = process(array, L, mid);
        int rightMax = process(array, mid + 1, R);
        return Math.max(leftMax, rightMax);
    }

}
